package danny.hoi.service.cargo.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import danny.hoi.dao.export.cargo.ExtEproductDao;
import danny.hoi.domain.export.cargo.ExtEproduct;
import danny.hoi.domain.export.cargo.ExtEproductExample;
import danny.hoi.service.cargo.ExtEproductService;
import danny.hoi.utils.UuidUtil;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

;

@Service
public class ExtEproductServiceImpl implements ExtEproductService {
    @Autowired
    private ExtEproductDao extEproductDao;

    @Override
    public List<ExtEproduct> findAll(ExtEproductExample example) {
        return extEproductDao.selectByExample(example);
    }

    @Override
    public PageInfo<ExtEproduct> findByPages(ExtEproductExample example, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<ExtEproduct> extEproducts = extEproductDao.selectByExample(example);

        return new PageInfo<>(extEproducts);
    }

    @Override
    public ExtEproduct findById(String id) {
        return extEproductDao.selectByPrimaryKey(id);
    }

    @Override
    public void save(ExtEproduct extEproduct) {
        extEproduct.setId(UuidUtil.getUuid());

        extEproductDao.insertSelective(extEproduct);
    }

    @Override
    public void update(ExtEproduct extEproduct) {
        extEproductDao.updateByPrimaryKeySelective(extEproduct);
    }

    @Override
    public void delete(String id) {
        extEproductDao.deleteByPrimaryKey(id);
    }
}
